// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
	env: cloud.DYNAMIC_CURRENT_ENV
})


exports.main = async (event, context) => {
	const res = await cloud.cloudPay.unifiedOrder({
		"body": event.goodName, //商品名称或商品描述
		"outTradeNo": event.id + '' + new Date().getTime(), //订单号
		"spbillCreateIp": "127.0.0.1",
		"subMchId": "1235896802", //****** 微信支付商户号
		"totalFee": event.totalFee, //支付的金额，单位分
		"envId": "youth-venture-0gah78uib696a43a", //云开发id
		"functionName": "callActivity",
		"nonceStr": Math.random().toString(36).substr(2) + '',
		"tradeType": 'JSAPI'
	})
	return res
}